<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>订单大厅</title>
    <link rel="stylesheet" href="__STATIC__/index/assets/sui/dist/css/sm.css">
    <link rel="stylesheet" href="//at.alicdn.com/t/font_2008579_4jc01siy42m.css">
    <link rel="stylesheet" href="__STATIC__/index/assets/css/index.css">
    <link rel="stylesheet" href="__STATIC__/index/assets/sui/dist/css/sm-extend.min.css">


</head>

<body>
<!-- page 容器 -->
<div class="page">
    <header class="bar bar-nav">
        <h1 class="title">大厅</h1>
    </header>
    <!-- 工具栏 -->
    <nav class="bar bar-tab">
        <a class="tab-item external" href="{:url('index/index')}">
            <span class="icon icon-home"></span>
            <span class="tab-label">首页</span>
        </a>
        <a class="tab-item external active" href="{:url('orderhall/index')}">
            <span class="icon iconfont icondating"></span>
            <span class="tab-label">大厅</span>
        </a>
        <a class="tab-item external" href="{:url('myorder/index')}">
            <span class="icon iconfont icondingdan"></span>
            <span class="tab-label">订单</span>
        </a>
        <a class="tab-item external" href="{:url('user/index')}">
            <span class="icon icon-me"></span>
            <span class="tab-label">我的</span>
        </a>
    </nav>
    <div class="content">
        {if !$orders}
        <div class="content-block order_list">
            <img class="no_order" src="__STATIC__/index/assets/image/no_order.png" alt="">
            <p class="no_order_tit">暂无订单</p>
        </div>
        {else /}
        <div class="list-block contacts-block dt_content">
            <div class="list-group">
                <ul class="dt_main">
                    {foreach $orders as $k=>$v}
                    <li class="dt_l">
                        <a href="" onclick="openOrder({$v['order_num']});" class="item-link item-content dt_list">
                            <img src="{$v.user_headimg}" alt="">
                            <div class="dt_cont">
                                <span>{$v.order_title}</span>
                                <span>￥{$v.order_price}</span>
                                <span>下单时间：{:date('Y-m-d H:i:s',$v.order_ctime)}</span>
                            </div>
                            <img class="dt_state" src="__STATIC__/index/assets/image/jinxing.png" alt="">
                        </a>
                    </li>
                    {/foreach}
                </ul>
            </div>
        </div>
        {/if}
    </div>
</div>
<script src='http://cdn.bootcss.com/jquery/3.1.1/jquery.min.js'></script>
<script src='__STATIC__/index/assets/sui/dist/js/sm.js'></script>
<script type='text/javascript' src='__STATIC__/index/assets/sui/dist/js/sm-extend.js' charset='utf-8'></script>
<script>
    function openOrder(order_num) {
        $.ajax({
            url: "{:url('myorder/checkOrder')}",
            type: "POST",
            data: {
                order_num:order_num
            },
            dataType: "json",
            success: function(res){
                if(!res.code){
                    var modal = $.modal({
                        title: '订单查看',
                        text: '成为送餐员才可以查看订单哦',
                        afterText:  '<div  style="width: auto; margin:3px">'+
                            '<img style="width: 60%;margin: 0 auto;" src="__STATIC__/index/assets/image/topeisong.png" alt="">'+
                            '</div>',
                        buttons: [
                            {
                                text: '成为送餐员',
                                onClick: function () {
                                    $.confirm('确定要申请配送员吗?', function () {
                                        $.ajax({
                                            url: "{:url('user/tosq')}",
                                            type: "POST",
                                            data: {},
                                            dataType: "json",
                                            success: function(data){
                                                $.toast(data.msg, 2000);
                                            }
                                        });
                                    });
                                }
                            },
                            {
                                text: '取消',
                                bold: true

                            },
                        ]
                    })
                }else{
                    window.location.href="/index/myorder/showOrder?order_num="+order_num;
                }
            }
        });
    }

</script>
</body>

</html>